/**
 * 调档审批的审批页面
 */
var vm = new Vue({
    el: "#main",
    data: {
        req_id: '',
        approval: "", // 审批回复
        status: '' // 审批状态
    },
    created: function() {
        var query = window.location.search.substring(1);
        var vars = query.split("&");
        var req_id = ''
    	var status = ''
		var approval = ''
        for (var i = 0; i < vars.length; i++) {
            var pair = vars[i].split("=");
            if (pair[0] == 'req_id') {
                req_id = pair[1]
                this.req_id = req_id
            }
            if (pair[0] == "status") {
            	status = pair[1];
            	this.status = status
            }
            if (pair[0] == 'approval') {
            	if (pair[1] == 'null') {
            		
            	} else {
            		approval = decodeURI(pair[1])
            	}
                this.approval = approval
                console.log(this.approval)
            }
        }
    },
    methods: {
        agreeBtn() {
            const _this = this
            axios({
                method: "post",
                // 审核接口
                url: App.envUrl.backtrackUrl+"approval/update",
                // url: "http://192.168.1.81:8080/slxt-web/approval/update",
                data: {reqId: _this.req_id,approval: this.approval,status: 1}
            }).then((data) => {
                if (data.data.ret == '00000') {
                    history.back(-1)
                } else {
                    parent.showAlert(data.data.msg)
                }
            }).catch((err) => {})
        },
        refuseBtn() {
            const _this = this
            axios({
                method: "post",
                // 审核接口
                url: App.envUrl.backtrackUrl+"approval/update",
                data: {reqId: _this.req_id,approval: this.approval,status: 2}
            }).then((data) => {
                if (data.data.ret == '10000') {
                    history.back(-1)
                } else {
                    parent.showAlert(data.data.msg)
                }
            }).catch((err) => {})
        },
        goBtn() {
            history.back(-1)
        }
    }
});